home *** CD-ROM | disk | FTP | other *** search
- /*
- ##########################################################################
- #### ####
- #### The MusicBox Project ####
- #### ============================ ####
- #### ####
- #### MusicBox.c ####
- #### ####
- #### Version 2.1os -- September 29, 2000 ####
- #### ####
- #### Copyright (C) 1994 Thomas Dreibholz ####
- #### 2000 Molbachweg 7 ####
- #### 51674 Wiehl ####
- #### Germany ####
- #### ####
- #### EMail: Dreibholz@bigfoot.com ####
- #### WWW: http://www.bigfoot.com/~dreibholz ####
- #### ####
- ##########################################################################
- */
- /***************************************************************************
- * *
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- * *
- ***************************************************************************/
-
- /* MusicBox Hauptprogramm */
-
- #include "MusicBox.h"
- #include "MusicBoxLibrary.h"
-
- void TesteLaufwerk();
- void Iconify();
- void ZeigeNum();
- void Num();
- void IntuiTicks();
- void Fill();
-
- struct Einstellungen Einstellungen=
- {
- 0,
- 0L,
- 255,255,
- AUDIO_LINKS,
- AUDIO_RECHTS,
- 0,
- 0,DATEN,0,
- 0,STANDBY,JOYSTICK_II,
- 01,
- 0,ZEIT_TICKS,0,0,255,0,0,0,0,0,
- 1,1,1,1,0,0,0
- };
-
- UBYTE *VerStr=VERSTR;
- UBYTE DeviceName[40];
- LONG UnitNumber=-1L;
- UBYTE ARexxName[40];
-
- struct Library *GfxBase;
- extern struct Library *IconBase;
- extern struct ExecBase *SysBase;
- struct Library *WorkbenchBase;
- struct Library *DiskfontBase;
- struct IntuitionBase *IntuitionBase;
- struct Library *GadToolsBase;
- struct Library *LocaleBase;
- struct Library *MusicBoxBase;
- struct Library *TimerBase;
- struct Library *AmigaGuideBase;
-
- extern int SetupScreen();
- extern int OpenCDPlayerWindow();
-
- extern struct Gadget *CDPlayerGadgets[27];
- extern struct Window *CDPlayerWnd;
- extern struct ThisCD *ThisCD;
- extern struct ThisDrive *ThisDrive;
- extern struct TextFont *Font;
- extern struct List Liste;
- extern struct DiskObject AudioCD;
- extern struct DiskObject CDMusicBox;
- extern struct VisualInfo *VisualInfo;
- extern struct WBenchMsg *WBenchMsg;
-
- struct Katalog *Katalog;
- struct Locale *Locale;
- struct Catalog *Catalog;
-
- BOOL WarteAufAudio=FALSE;
- BOOL IstDatenCD=FALSE;
- BOOL IsIconify=FALSE;
- BOOL DivLevel=FALSE;
-
- BOOL Quiet=FALSE;
- BOOL USModus=FALSE;
- BOOL LowRes=FALSE;
- BOOL NoReq=FALSE;
- BOOL NoTT=FALSE;
- BOOL FastExit=FALSE;
-
- int ox,oy;
- LONG ProcessSignal=-1L;
- ULONG IDCMPSignalMask,
- AppSignalMask,
- ProcessSignalMask,
- ControlSignalMask,
- ARexxSignalMask;
- ULONG WaitSignalMask;
-
-
- struct TextAttr DisplayAttr={"hifi-display.font",18,FS_NORMAL,FPF_DISKFONT};
- struct TextAttr SmallAttr={"hifi-display.font",7,FS_NORMAL,FPF_DISKFONT};
- struct TextAttr TimesAttr={"times.font",18,FS_NORMAL,FPF_DISKFONT};
-
- struct TextFont *DisplayFont;
- struct TextFont *SmallFont;
- struct TextFont *TimesFont;
- struct RastPort *RPort;
- struct MsgPort *AppPort;
- struct MsgPort *ControlPort;
- struct MsgPort *ARexxPort;
- struct AppIcon *AppIcon;
- struct AppMenuItem *AppItem;
- struct AppMessage *AppMsg;
-
- void PutText(x,y,text)
- int x,y;
- UBYTE *text;
- {
- /*
- Move(RPort,x+ox,y+oy);
- Text(RPort,text,strlen(text));
- */
- PutTextA(CDPlayerWnd,x,y,text);
- }
-
- UBYTE *GS(num,def)
- LONG num;
- UBYTE *def;
- {
- if(Catalog==NULL) return(def);
- return(GetCatalogStr(Catalog,num,def));
- }
-
- void ZeigeVolumen()
- {
- UBYTE text[6];
-
- if(IsIconify) return;
-
- SetAPen(RPort,FARBE);
- SetFont(RPort,SmallFont);
- sprintf(&text,"A%3d",Einstellungen.VolumenL);
- PutText(14+(13*22),25,&text);
- sprintf(&text,"B%3d",Einstellungen.VolumenR);
- PutText(14+(13*22),34,&text);
- SetFont(RPort,DisplayFont);
- }
-
- void ZeigeLR()
- {
- UBYTE text[2];
-
- if(IsIconify) return;
-
- text[1]=0x00;
- if(Einstellungen.AudioL!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
- text[0]=Einstellungen.AudioL+((UBYTE)'!'-1);
- PutText(5+(12*22)-5,35,&text);
- if(Einstellungen.AudioR!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
- text[0]=Einstellungen.AudioR+(UBYTE)'#';
- PutText(5+(16*22),35,&text);
-
- SetzeLR();
- }
-
- void ZeigeCDInfo()
- {
- if(IsIconify) return;
-
- if(Einstellungen.AutoStart!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
- PutText(5+(4*22),35,"*");
- if(Einstellungen.AutoRepeat!=0) SetAPen(RPort,FARBE); else SetAPen(RPort,0);
- PutText(5+(5*22),35,")");
-
- SetAPen(RPort,FARBE);
- if(Einstellungen.Lock)
- PutText(5+(6*22),35,"]");
- else
- PutText(5+(6*22),35,"(");
- if(Einstellungen.CDEingelegt)
- {
- PutText(5+(7*22),35,"R");
- switch(Einstellungen.CDTyp)
- {
- case DATEN:
- PutText(5+(8*22),35,"X");
- break;
- case AUDIO:
- PutText(5+(8*22),35,"Y");
- break;
- }
- switch(Einstellungen.CDTyp)
- {
- case DATEN:
- PutText(5+(8*22),35,"X");
- break;
- case AUDIO:
- PutText(5+(8*22),35,"Y");
- break;
- }
- if(Einstellungen.CDKatalogisiert)
- PutText(5+(9*22),35,"[");
- else
- PutText(5+(9*22),35,"P");
- }
- else
- {
- PutText(5+(7*22),35,"Q ");
- }
- }
-
- void ZeigeTrackDisplay()
- {
- REGISTER ULONG adr,prozent;
- REGISTER UBYTE frame,track,min,sek;
- UWORD i,j;
- UBYTE text[80],zeichen;
- struct DateStamp ds;
- struct TagItem tag[3];
-
- if(!(Einstellungen.Funktion==POSITION)) LeseStatus();
- if(IsIconify) return;
-
- if(Einstellungen.Adresse>ThisCD->Endadresse)
- Einstellungen.Adresse=ThisCD->Endadresse;
- if(Einstellungen.Adresse<ThisCD->Startadresse)
- Einstellungen.Adresse=ThisCD->Startadresse;
-
- tag[0].ti_Tag=GTSL_Max;
- tag[1].ti_Tag=GTSL_Level;
- tag[2].ti_Tag=TAG_DONE;
-
- SetAPen(RPort,FARBE);
- if(Einstellungen.Funktion!=STANDBY)
- {
- tag[0].ti_Data=ThisCD->Track[Einstellungen.Track-1].TAdresse-225;
- tag[1].ti_Data=Einstellungen.Adresse-
- ThisCD->Track[Einstellungen.Track-1].SAdresse;
- if(tag[0].ti_Data>32000)
- {
- DivLevel=TRUE;
- tag[0].ti_Data/=2;
- tag[1].ti_Data/=2;
- }
- else DivLevel=FALSE;
- if(tag[1].ti_Data>tag[0].ti_Data) tag[1].ti_Data=tag[0].ti_Data;
- switch(Einstellungen.Anzeige)
- {
- case TRACK_ANFANG:
- track=Einstellungen.Track;
- adr=Einstellungen.Adresse-ThisCD->Track[Einstellungen.Track-1].SAdresse;
- prozent=(1000*adr)/ThisCD->Track[Einstellungen.Track-1].TAdresse;
- zeichen='l';
- break;
- case TRACK_ENDE:
- adr=ThisCD->Track[Einstellungen.Track-1].TAdresse+
- ThisCD->Track[Einstellungen.Track-1].SAdresse-
- Einstellungen.Adresse;
- prozent=(1000*adr)/ThisCD->Track[Einstellungen.Track-1].TAdresse;
- zeichen='m';
- break;
- case CD_ANFANG:
- adr=Einstellungen.Adresse;
- prozent=(1000*adr)/ThisCD->Endadresse;
- zeichen='n';
- break;
- case CD_ENDE:
- adr=ThisCD->Endadresse-Einstellungen.Adresse;
- prozent=(1000*adr)/ThisCD->Endadresse;
- zeichen='o';
- break;
- }
-
- min=(adr/75/60);
- sek=((adr/75) % 60);
- frame=(adr % 75);
-
- if(Einstellungen.Format==ZEIT)
- {
- if(Einstellungen.Funktion==WIEDERGABE)
- {
- sprintf(&text,"%02d %c%02d:%02d ^ ",
- Einstellungen.Track,
- zeichen,
- min,
- sek);
- }
- else
- {
- sprintf(&text,"%02d %c%02d:%02d ^%02d",
- Einstellungen.Track,
- zeichen,
- min,
- sek,
- frame);
- }
- }
- else if(Einstellungen.Format==ADRESSE)
- {
- zeichen+=4;
- sprintf(&text,"%02d %c %05lx",
- Einstellungen.Track,
- zeichen,
- adr);
- }
- else if(Einstellungen.Format==MEGABYTES)
- {
- zeichen+=12;
- sprintf(&text,"%02d %c%4ld.%ld",
- Einstellungen.Track,
- zeichen,
- adr/512,(adr % 512)/52);
- }
- else
- {
- zeichen+=8;
- sprintf(&text,"%02d %c%3ld.%ld",
- Einstellungen.Track,
- zeichen,
- prozent/10,
- prozent % 10);
- }
- }
- else
- {
- tag[0].ti_Data=0;
- tag[1].ti_Data=0;
- DateStamp(&ds);
- sprintf(&text,"-- S%2d:%02d T%02d",
- ds.ds_Minute/60,
- ds.ds_Minute % 60,
- ds.ds_Tick / 50);
- }
- j=strlen(&text);
- if(j<14)
- for(i=j;i<15;i++) strcat(&text," ");
- PutText(5+22,10,&text);
- GTSetGadgetAttrsA(CDPlayerGadgets[27],CDPlayerWnd,NULL,&tag);
-
- if(Einstellungen.Titel!=Einstellungen.Track)
- {
- Einstellungen.Titel=Einstellungen.Track;
- if(Einstellungen.CDEingelegt)
- {
- WarteAufAudio=FALSE;
- if(Einstellungen.CDTyp==AUDIO)
- {
- IstDatenCD=FALSE;
- sprintf(&text,"%s (%d:%02d '%02d)",
- &Katalog->KE[Einstellungen.Track-1].Titel,
- ThisCD->Track[Einstellungen.Track-1].TMinute,
- ThisCD->Track[Einstellungen.Track-1].TSekunde,
- ThisCD->Track[Einstellungen.Track-1].TFrame);
- SetFont(RPort,TimesFont);
- Fill();
- if(LowRes==TRUE)
- {
- PutMText(CDPlayerWnd,11,152,&Katalog->CDName,430);
- PutMText(CDPlayerWnd,11,171,&text,570);
- }
- else
- {
- PutMText(CDPlayerWnd,11,196,&Katalog->CDName,430);
- PutMText(CDPlayerWnd,11,215,&text,570);
- }
- }
- else
- {
- if(IstDatenCD==FALSE)
- {
- SetFont(RPort,TimesFont);
- Fill();
- if(LowRes==FALSE)
- PutText(11,205,GS(39,"-- The inserted disc is a data CD --"));
- else
- PutText(11,160,GS(39,"-- The inserted disc is a data CD --"));
- IstDatenCD=TRUE;
- }
- }
- }
- else
- {
- IstDatenCD=FALSE;
- if(WarteAufAudio==FALSE)
- {
- SetFont(RPort,TimesFont);
- Fill();
- if(LowRes==FALSE)
- PutText(11,205,GS(40,"-- Please insert an audio CD --"));
- else
- PutText(11,160,GS(40,"-- Please insert an audio CD --"));
- WarteAufAudio=TRUE;
- }
- }
- SetFont(RPort,DisplayFont);
- if(LowRes==FALSE)
- PutText(600,220,"?");
- else
- PutText(600,174,"?");
- }
- }
-
- void Fill()
- {
- SetAPen(RPort,0);
- if(LowRes==FALSE)
- {
- RectFill(RPort,ox + 0, oy + 183, ox+465, oy+221);
- RectFill(RPort,ox + 466, oy + 203, ox+621, oy+221);
- }
- else
- {
- RectFill(RPort,ox + 0, oy + 139, ox+465, oy+175);
- RectFill(RPort,ox + 466, oy + 155, ox+621, oy+175);
- }
- SetAPen(RPort,FARBE);
- }
-
- void Symbol(num)
- UBYTE num;
- {
- if(IsIconify) return;
-
- SetAPen(RPort,FARBE);
- switch(num)
- {
- case WIEDERGABE:
- PutText(5,35,"<");
- break;
- case STOP:
- PutText(5,35,";");
- break;
- case PAUSE:
- PutText(5,35,"=");
- break;
- case STANDBY:
- PutText(5,35,">");
- break;
- case VORLAUF:
- PutText(5,35,"h");
- break;
- case RUECKLAUF:
- PutText(5,35,"g");
- break;
- case PLUS:
- PutText(5,35,"i");
- break;
- case MINUS:
- PutText(5,35,"j");
- break;
- case AUTO:
- PutText(5,35,"U");
- break;
- case POSITION:
- PutText(5,35,"+");
- break;
- }
-
- }
-
- void ZeigeStatus()
- {
- if(IsIconify) return;
-
- if((Einstellungen.Funktion==VORLAUF)||(Einstellungen.Funktion==RUECKLAUF))
- Einstellungen.TickCnt=1;
- else if(Einstellungen.Funktion==STANDBY)
- Einstellungen.TickCnt=8;
- else
- if(Einstellungen.Format==ADRESSE)
- Einstellungen.TickCnt=ADRESSE_TICKS;
- else
- Einstellungen.TickCnt=ZEIT_TICKS;
-
- Symbol(Einstellungen.Funktion);
-
- switch(Einstellungen.SCSI)
- {
- case 1:
- PutText(5+22,35,"V");
- break;
- case 0:
- PutText(5+22,35,"\\");
- break;
- case 2:
- PutText(5+22,35,"k");
- break;
- }
-
- switch(Einstellungen.Kontrolle)
- {
- case AUS:
- PutText(5+(2*22),35,"M");
- break;
- case JOYSTICK_I:
- PutText(5+(2*22),35,"J");
- break;
- case JOYSTICK_II:
- PutText(5+(2*22),35,"K");
- break;
- }
-
- ZeigeTrackDisplay();
- ZeigeNum();
- }
-
- void CDDisplay()
- {
- if(IsIconify) return;
-
- SetAPen(RPort,FARBE);
- SetFont(RPort,DisplayFont);
-
- ZeigeStatus();
- ZeigeCDInfo();
- ZeigeLR();
- ZeigeVolumen();
-
- PutText(5,10,"`");
- if(Einstellungen.Toshiba) PutText(5+(16*22),10,"_");
- if(LowRes==FALSE)
- PutText(600,220,"?");
- else
- PutText(600,174,"?");
- }
-
-
- void CloseAll()
- {
- CloseCDPlayerWindow();
- CloseDownScreen();
- EntferneProzess();
- if(TimesFont)
- {
- if(Einstellungen.AutoFlush) RemFont(TimesFont);
- CloseFont(TimesFont);
- }
- if(DisplayFont)
- {
- if(Einstellungen.AutoFlush) RemFont(DisplayFont);
- CloseFont(DisplayFont);
- }
- if(SmallFont)
- {
- if(Einstellungen.AutoFlush) RemFont(SmallFont);
- CloseFont(SmallFont);
- }
- EntferneSCSI();
- EntferneIcon();
- if(Katalog) FreeMem(Katalog,sizeof(struct Katalog));
- if(ARexxPort) DeletePortA(ARexxPort);
- if(AppPort) DeletePortA(AppPort);
- if(ControlPort) DeleteMMPort(ControlPort);
- if(ProcessSignal!=-1L) FreeSignal(ProcessSignal);
- if(TimerBase)
- {
- Forbid();
- TimerBase->lib_OpenCnt--;
- Permit();
- }
- if(MusicBoxBase)
- {
- if(Einstellungen.AutoFlush)
- KillLibrary(MusicBoxBase);
- else
- CloseLibrary(MusicBoxBase);
- }
- if(GfxBase) CloseLibrary(GfxBase);
- if(IntuitionBase) CloseLibrary(IntuitionBase);
- if(IconBase) CloseLibrary(IconBase);
- if(LocaleBase)
- {
- if(Catalog) CloseCatalog(Catalog);
- if(Locale) CloseLocale(Locale);
- CloseLibrary(LocaleBase);
- }
- if(WorkbenchBase) CloseLibrary(WorkbenchBase);
- if(DiskfontBase)
- {
- if(Einstellungen.AutoFlush)
- KillLibrary(DiskfontBase);
- else
- CloseLibrary(DiskfontBase);
- }
- if(AmigaGuideBase)
- {
- if(Einstellungen.AutoFlush)
- KillLibrary(AmigaGuideBase);
- else
- CloseLibrary(AmigaGuideBase);
- }
- if(GadToolsBase) CloseLibrary(GadToolsBase);
- exit(0);
- }
-
- void OpenAll()
- {
- UBYTE name[40],unit[10];
- register long test;
-
- if(USModus==FALSE)
- {
- LocaleBase=OpenLibrary("locale.library",38L);
- if(LocaleBase!=NULL)
- {
- Locale=OpenLocale(NULL);
- if(Locale!=NULL)
- Catalog=OpenCatalogA(Locale,"musicbox.catalog",NULL);
- }
- }
- GfxBase=OpenLibrary("graphics.library",37L);
- IntuitionBase=OpenLibrary("intuition.library",37L);
- if((GfxBase==NULL)||(IntuitionBase==NULL))
- {
- puts(GS(1,"This program requires Kickstart 2.0, V37!"));
- CloseAll();
- }
- MusicBoxBase=OpenLibrary("musicbox.library",0L);
- if(MusicBoxBase==NULL)
- {
- Error(GS(55,"Unable to open musicbox.library!"));
- CloseAll();
- }
- if((UnIconifyMusicBox())==0)
- CloseAll();
- if((LibVersionCheck(VERSION))==0)
- CloseAll();
- AmigaGuideBase=OpenLibrary("amigaguide.library",0L);
- IconBase=OpenLibrary("icon.library",0L);
- if(IconBase==NULL)
- {
- Error(GS(2,"Unable to open icon.library!"));
- CloseAll();
- }
- WorkbenchBase=OpenLibrary("workbench.library",37L);
- if(WorkbenchBase==NULL)
- {
- Error(GS(3,"Unable to open workbench.library!"));
- CloseAll();
- }
- GadToolsBase=OpenLibrary("gadtools.library",37L);
- if(GadToolsBase==NULL)
- {
- Error(GS(4,"Unable to open gadtools.library!"));
- CloseAll();
- }
- DiskfontBase=OpenLibrary("diskfont.library",0L);
- if(DiskfontBase==NULL)
- {
- Error(GS(4,"Unable to open diskfont.library!"));
- CloseAll();
- }
- Forbid();
- TimerBase=FindName(&SysBase->DeviceList,"timer.device");
- if(TimerBase!=NULL) TimerBase->lib_OpenCnt++;
- Permit();
- Randomize();
- if(TimerBase==NULL)
- {
- Error(GS(74,"Where is the timer.device?"));
- CloseAll();
- }
- Katalog=AllocMem(sizeof(struct Katalog),MEMF_ANY);
- if(Katalog==NULL)
- {
- Error(GS(6,"Not enough memory!"));
- CloseAll();
- }
-
- test=GetVar("CDROM_DEVICE",&name,38,0);
- if(test==-1)
- {
- if(DeviceName[0]==0x00)
- {
- Error(GS(7,"Music Box requires the ENV-variable\n"
- "CDROM_DEVICE\n"
- "or the ToolTypes-entry\n"
- "DEVICE=<name>\n"
- "with the name of your SCSI-device!\n"
- "You must create it before starting MusicBox!\n"
- "Example: SetENV CDROM_DEVICE scsi.device"));
- CloseAll();
- }
- }
- else
- strcpy(&DeviceName,&name);
-
- test=GetVar("CDROM_UNIT",&unit,8,0);
- if(test==-1)
- {
- if(UnitNumber==-1)
- {
- Error(GS(8,"Music Box requires the ENV-variable\n"
- "CDROM_UNIT\n"
- "or the ToolTypes-entry\n"
- "UNIT=<number>\n"
- "with the unit number of your CD-ROM-drive!\n"
- "You must create it before starting MusicBox!\n"
- "Example: SetENV CDROM_UNIT 6"));
- CloseAll();
- }
- }
- else
- UnitNumber=atol(&unit);
-
- test=InitSCSI(&DeviceName,UnitNumber);
- if(test!=0)
- CloseAll();
- test=InitIcon();
- if(test==FALSE) return;
- DisplayFont=OpenDiskFont(&DisplayAttr);
- if(DisplayFont==NULL)
- {
- Error(GS(9,"Unable to open font: hifi-display.font 18"));
- CloseAll();
- }
- SmallFont=OpenDiskFont(&SmallAttr);
- if(SmallFont==NULL)
- {
- Error(GS(10,"Unable to open font: hifi-display.font 7"));
- CloseAll();
- }
- TimesFont=OpenDiskFont(&TimesAttr);
- if(TimesFont==NULL)
- {
- Error(GS(11,"Unable to open font: times.font 18"));
- CloseAll();
- }
- test=SetupScreen();
- if(test!=0)
- CloseAll();
- AppPort=CreatePortA(0L,0L);
- ControlPort=CreatePortA(MUSICBOX_HOSTNAME,0L);
- ARexxPort=CreatePortA(&ARexxName,2L);
- if((AppPort==NULL)||(ControlPort==NULL)||(ARexxPort==NULL))
- {
- Error(GS(12,"Unable to create message ports!"));
- CloseAll();
- }
- ProcessSignal=AllocSignal(-1L);
- if(ProcessSignal==-1L)
- {
- Error(GS(13,"Not enough free task signals!"));
- CloseAll();
- }
- NewListA(&Liste);
- test=InitProzess();
- if(test)
- {
- Error(GS(14,"Unable to create process for display"));
- CloseAll();
- }
- IsIconify=TRUE;
- PrefsLaden();
- IsIconify=FALSE;
-
- if(Einstellungen.AutoLoad)
- {
- if(LowRes==FALSE)
- OpenArchive(0,0,OA_QUIET);
- else
- OpenArchive(0,0,OA_QUIET|OA_LOWRES);
- }
-
- ProcessSignalMask=(1L<<ProcessSignal);
- AppSignalMask=(1L<<AppPort->mp_SigBit);
- ControlSignalMask=(1L<<ControlPort->mp_SigBit);
- ARexxSignalMask=(1L<<ARexxPort->mp_SigBit);
-
- if(Quiet==FALSE)
- {
- test=OpenCDPlayerWindow();
- if(test!=0)
- CloseAll();
- }
- else
- Iconify();
-
- RPort=CDPlayerWnd->RPort;
- ox=OffsetX(CDPlayerWnd);
- oy=OffsetY(CDPlayerWnd);
-
- IDCMPSignalMask=(1L<<CDPlayerWnd->UserPort->mp_SigBit);
- WaitSignalMask=IDCMPSignalMask+ProcessSignalMask+ControlSignalMask+ARexxSignalMask;
-
- CDDisplay();
- PrefsZeigen();
- TesteLaufwerk();
- }
-
-
- void main(argc,argv)
- long argc;
- UBYTE *argv[];
- {
- REGISTER ULONG Signale;
- REGISTER int test;
- REGISTER UBYTE *name;
- register struct WBArg *wb;
- register struct DiskObject *di;
-
- if(argc>1)
- {
- if(!(strcmp(argv[1],"?")))
- {
- printf("USAGE: %s [-i|IGNORETOOLTYPES -q|QUIET -u|US\n",argv[0]);
- puts(" -l|LOWRES -r|NOREQ -f|FASTEXIT]");
- exit(0);
- }
- for(test=1;test<argc;test++)
- {
- if(!(strcmp(argv[test],"-q"))) Quiet=TRUE;
- if(!(strcmp(argv[test],"QUIET"))) Quiet=TRUE;
- if(!(strcmp(argv[test],"-u"))) USModus=TRUE;
- if(!(strcmp(argv[test],"US"))) USModus=TRUE;
- if(!(strcmp(argv[test],"-l"))) LowRes=TRUE;
- if(!(strcmp(argv[test],"LOWRES"))) LowRes=TRUE;
- if(!(strcmp(argv[test],"-r"))) NoReq=TRUE;
- if(!(strcmp(argv[test],"NOREQ"))) NoReq=TRUE;
- if(!(strcmp(argv[test],"-i"))) NoTT=TRUE;
- if(!(strcmp(argv[test],"IGNORETOOLTYPES"))) NoTT=TRUE;
- if(!(strcmp(argv[test],"-f"))) FastExit=TRUE;
- if(!(strcmp(argv[test],"FASTEXIT"))) FastExit=TRUE;
- }
- }
-
- if(argc==0)
- {
- wb=WBenchMsg->sm_ArgList;
- name=wb->wa_Name;
- }
- else
- name=argv[0];
-
- DeviceName[0]=0x00;
- sprintf(&ARexxName,"MusicBoxARexx");
- if(NoTT==FALSE)
- {
- IconBase=OpenLibrary("icon.library",0L);
- if(IconBase!=NULL)
- {
- di=GetDiskObject(name);
- if(di!=NULL)
- {
- name=FindToolType(di->do_ToolTypes,"QUIET");
- if(name) if((MatchToolValue(name,"ON"))) Quiet=TRUE;
- name=FindToolType(di->do_ToolTypes,"FASTEXIT");
- if(name) if((MatchToolValue(name,"ON"))) FastExit=TRUE;
- name=FindToolType(di->do_ToolTypes,"US");
- if(name) if((MatchToolValue(name,"ON"))) USModus=TRUE;
- name=FindToolType(di->do_ToolTypes,"LOWRES");
- if(name) if((MatchToolValue(name,"ON"))) LowRes=TRUE;
- name=FindToolType(di->do_ToolTypes,"DEVICE");
- if(name)
- {
- test=strlen(name); if(test>38) test=38;
- CopyMem(name,&DeviceName,test);
- DeviceName[39]=0x00;
- }
- name=FindToolType(di->do_ToolTypes,"AREXXPORT");
- if(name)
- {
- test=strlen(name); if(test>38) test=38;
- CopyMem(name,&ARexxName,test);
- ARexxName[39]=0x00;
- }
- name=FindToolType(di->do_ToolTypes,"UNIT");
- if(name) UnitNumber=atol(name);
- FreeDiskObject(di);
- }
- CloseLibrary(IconBase);
- IconBase=NULL;
- }
- }
-
- OpenAll();
-
- do
- {
- Signale=Wait(WaitSignalMask);
- if(Signale & IDCMPSignalMask)
- test=HandleCDPlayerIDCMP();
- if(Signale & ProcessSignalMask)
- IntuiTicks();
- if(Signale & ControlSignalMask)
- if((ControlHandler())==1) test=2;
- if(Signale & ARexxSignalMask)
- if((ARexxHandler())==1) test=2;
-
- if(test==2)
- {
- Iconify();
- test=1;
- }
- } while(test==1);
-
- CloseAll();
- }
-
- void ZeigeNum()
- {
- struct TagItem tagr[3];
- UBYTE text[6];
-
- if(IsIconify) return;
-
- if(Einstellungen.NumS==1)
- sprintf(&text,"%d_",Einstellungen.Num);
- else if(Einstellungen.NumS==2)
- sprintf(&text,"%02d",Einstellungen.Num);
- else
- strcpy(&text,"__");
-
- SetAPen(RPort,FARBE);
- SetFont(RPort,Font);
- if(LowRes==FALSE)
- PutText(308,164,&text);
- else
- {
- PutText(305,125,&text);
- tagr[0].ti_Tag = GT_VisualInfo;
- tagr[0].ti_Data = VisualInfo;
- tagr[1].ti_Tag = GTBB_Recessed;
- tagr[1].ti_Data = TRUE;
- tagr[2].ti_Tag = TAG_DONE;
- DrawBevelBox2( CDPlayerWnd->RPort, ox + 296, oy + 152, 37, 19, &tagr);
- }
- SetFont(RPort,DisplayFont);
- }
-
- void Num(n)
- UBYTE n;
- {
- REGISTER UBYTE a,b;
-
- if(IsIconify) return;
-
- SetAPen(RPort,FARBE);
- SetFont(RPort,Font);
- if((Einstellungen.CDEingelegt)&&(Einstellungen.CDTyp==AUDIO))
- {
- a=ThisCD->Anzahl / 10;
- b=ThisCD->Anzahl % 10;
- if(Einstellungen.NumS!=1)
- {
- Einstellungen.Num=n;
- if(n>a)
- {
- Einstellungen.NumS=2;
- if(Einstellungen.Num<1) Einstellungen.Num=1;
- if(Einstellungen.Num<1) Einstellungen.Num=1;
- if(Einstellungen.Num>ThisCD->Anzahl) Einstellungen.Num=ThisCD->Anzahl;
- }
- else Einstellungen.NumS=1;
- }
- else
- {
- Einstellungen.Num=Einstellungen.Num*10+n;
- Einstellungen.NumS=2;
- if(Einstellungen.Num<1) Einstellungen.Num=1;
- if(Einstellungen.Num>ThisCD->Anzahl) Einstellungen.Num=ThisCD->Anzahl;
- }
- }
- else
- Einstellungen.NumS=0;
- ZeigeNum();
- }
-
- void T0Clicked(){ Num(0); }
- void T1Clicked(){ Num(1); }
- void T2Clicked(){ Num(2); }
- void T3Clicked(){ Num(3); }
- void T4Clicked(){ Num(4); }
- void T5Clicked(){ Num(5); }
- void T6Clicked(){ Num(6); }
- void T7Clicked(){ Num(7); }
- void T8Clicked(){ Num(8); }
- void T9Clicked(){ Num(9); }
-
- void TSternClicked()
- {
- if((Einstellungen.CDEingelegt)&&(Einstellungen.CDTyp==AUDIO))
- {
- if(Einstellungen.NumS!=0)
- {
- if(Einstellungen.Track!=Einstellungen.Num)
- {
- if(Einstellungen.Track>Einstellungen.Num)
- Symbol(MINUS);
- else
- Symbol(PLUS);
- Einstellungen.Track=Einstellungen.Num;
- Einstellungen.Funktion=STOP;
- Wiedergabe();
- Einstellungen.Funktion=WIEDERGABE;
- Einstellungen.NumS=0;
- ZeigeNum();
- ZeigeTrackDisplay();
- }
- }
- }
- }
-
- void TClearClicked()
- {
- Einstellungen.NumS=0;
- ZeigeNum();
- }
-
- void TNumberClicked()
- {
- register int i;
-
- if(Einstellungen.Funktion!=STANDBY)
- {
- Randomize();
- i=Random(ThisCD->Anzahl);
- if(i>Einstellungen.Track) Symbol(PLUS); else Symbol(MINUS);
- Einstellungen.Funktion=STOP;
- Einstellungen.Track=i;
- Wiedergabe();
- Einstellungen.Funktion=WIEDERGABE;
- ZeigeTrackDisplay();
- }
- }
-
- void ListeClicked(dummy,code)
- BOOL dummy;
- UWORD code;
- {
- register struct StringInfo *si;
-
- if(code!=Einstellungen.Auswahl)
- {
- si=CDPlayerGadgets[24]->SpecialInfo;
- if(code==0)
- strcpy(si->Buffer,&Katalog->CDName);
- else
- strcpy(si->Buffer,&Katalog->KE[code-1].Titel);
- RefreshGList(CDPlayerGadgets[24],CDPlayerWnd,NULL,1L);
-
- Einstellungen.Auswahl=code;
- }
- else
- {
- if(code!=0)
- {
- Einstellungen.Funktion=STOP;
- Einstellungen.Track=code;
- Wiedergabe();
- }
- }
- }
-
- void AuswahlmodusClicked(dummy,code)
- BOOL dummy;
- UWORD code;
- {
- Einstellungen.Auswahlmodus=code;
- Randomize();
- }
-
- void StopClicked()
- {
- if((Einstellungen.Funktion==AUTO)||(Einstellungen.Funktion==WIEDERGABE)||(Einstellungen.Funktion==PAUSE)||(Einstellungen.Funktion==RUECKLAUF)||(Einstellungen.Funktion==VORLAUF))
- {
- Symbol(STOP);
- Stop();
- Einstellungen.Funktion=STOP;
- ZeigeStatus();
- }
- }
-
- void WiedergabeClicked()
- {
- if(!(Einstellungen.Funktion==STANDBY))
- {
- if(Einstellungen.Funktion==WIEDERGABE)
- {
- Symbol(PAUSE);
- Pause();
- Einstellungen.Funktion=PAUSE;
- }
- else
- {
- Symbol(WIEDERGABE);
- Wiedergabe();
- Einstellungen.Funktion=WIEDERGABE;
- }
- ZeigeStatus();
- }
- }
-
- void RuecklaufClicked()
- {
- if(!(Einstellungen.Funktion==STANDBY))
- {
- Einstellungen.Funktion=RUECKLAUF;
- Pause();
- ZeigeStatus();
- }
- }
-
- void VorlaufClicked()
- {
- if(!(Einstellungen.Funktion==STANDBY))
- {
- Einstellungen.Funktion=VORLAUF;
- Pause();
- ZeigeStatus();
- }
- }
-
- void MinusClicked()
- {
- if(!(Einstellungen.Funktion==STANDBY))
- {
- if(Einstellungen.Track>1)
- {
- Symbol(MINUS);
- Einstellungen.Funktion=MINUS;
- Einstellungen.Track--;
- Wiedergabe();
- Einstellungen.Funktion=WIEDERGABE;
- ZeigeTrackDisplay();
- }
- }
- }
-
- void PlusClicked()
- {
- if(!(Einstellungen.Funktion==STANDBY))
- {
- if(Einstellungen.Track<ThisCD->Anzahl)
- {
- Symbol(PLUS);
- Einstellungen.Funktion=PLUS;
- Einstellungen.Track++;
- Wiedergabe();
- Einstellungen.Funktion=WIEDERGABE;
- ZeigeTrackDisplay();
- }
- }
- }
-
- void AuswurfClicked()
- {
- if(!(Einstellungen.Lock))
- {
- Symbol(STANDBY);
- Auswurf();
- Einstellungen.Funktion=STANDBY;
- ZeigeStatus();
- ZeigeCDInfo();
- }
- }
-
- void LockClicked()
- {
- if(Einstellungen.Lock) Einstellungen.Lock=0; else Einstellungen.Lock=1;
- AuswurfLock();
- ZeigeCDInfo();
- }
-
- void PositionClicked(gadgetUp,code)
- BOOL gadgetUp;
- UWORD code;
- {
- REGISTER ULONG c;
-
- if(DivLevel==TRUE) c=code+code; else c=code;
- if(Einstellungen.Funktion!=STANDBY)
- {
- if(gadgetUp==FALSE)
- {
- Einstellungen.Funktion=POSITION;
- Einstellungen.Adresse=ThisCD->Track[Einstellungen.Track-1].SAdresse+c;
- ZeigeTrackDisplay();
- }
- else
- {
- Einstellungen.Funktion=PAUSE;
- Einstellungen.Adresse=ThisCD->Track[Einstellungen.Track-1].SAdresse+c;
- Continue();
- Einstellungen.Funktion=WIEDERGABE;
- ZeigeTrackDisplay();
- }
- }
- }
-
- void VolumeLClicked(dummy,code)
- BOOL dummy;
- UWORD code;
- {
- struct TagItem tag[2];
-
- Einstellungen.VolumenL=code;
- if(Einstellungen.Kopplung)
- {
- Einstellungen.VolumenR=Einstellungen.VolumenL;
- tag[0].ti_Tag=GTSL_Level;
- tag[0].ti_Data=Einstellungen.VolumenR;
- tag[1].ti_Tag=TAG_DONE;
- GTSetGadgetAttrsA(CDPlayerGadgets[25],CDPlayerWnd,NULL,&tag);
- }
- Volumen();
- ZeigeVolumen();
- }
-
- void VolumeRClicked(dummy,code)
- BOOL dummy;
- UWORD code;
- {
- struct TagItem tag[2];
-
- Einstellungen.VolumenR=code;
- if(Einstellungen.Kopplung)
- {
- Einstellungen.VolumenL=Einstellungen.VolumenR;
- tag[0].ti_Tag=GTSL_Level;
- tag[0].ti_Data=Einstellungen.VolumenL;
- tag[1].ti_Tag=TAG_DONE;
- GTSetGadgetAttrsA(CDPlayerGadgets[23],CDPlayerWnd,NULL,&tag);
- }
- Volumen();
- ZeigeVolumen();
- }
-
- void AudioLClicked(dummy,code)
- BOOL dummy;
- UWORD code;
- {
- struct TagItem tag[2];
-
- switch(code)
- {
- case 0:
- Einstellungen.AudioL=AUDIO_LINKS;
- break;
- case 1:
- Einstellungen.AudioL=AUDIO_RECHTS;
- break;
- case 2:
- Einstellungen.AudioL=AUDIO_BEIDE;
- break;
- case 3:
- Einstellungen.AudioL=AUDIO_AUS;
- break;
- }
-
- tag[0].ti_Tag=GTCY_Active;
- tag[0].ti_Data=code;
- tag[1].ti_Tag=TAG_DONE;
- GTSetGadgetAttrsA(CDPlayerGadgets[21],CDPlayerWnd,NULL,&tag);
-
- ZeigeLR();
- }
-
- void AudioRClicked(dummy,code)
- BOOL dummy;
- UWORD code;
- {
- struct TagItem tag[2];
-
- switch(code)
- {
- case 1:
- Einstellungen.AudioR=AUDIO_LINKS;
- break;
- case 0:
- Einstellungen.AudioR=AUDIO_RECHTS;
- break;
- case 2:
- Einstellungen.AudioR=AUDIO_BEIDE;
- break;
- case 3:
- Einstellungen.AudioR=AUDIO_AUS;
- break;
- }
-
- tag[0].ti_Tag=GTCY_Active;
- tag[0].ti_Data=code;
- tag[1].ti_Tag=TAG_DONE;
- GTSetGadgetAttrsA(CDPlayerGadgets[22],CDPlayerWnd,NULL,&tag);
-
- ZeigeLR();
- }
-
- void TitelClicked()
- {
- struct TagItem tag[2];
- register struct StringInfo *si;
-
- if(Einstellungen.CDEingelegt)
- {
- if(Einstellungen.Auswahl!=255)
- {
- si=CDPlayerGadgets[24]->SpecialInfo;
- if(Einstellungen.Auswahl==0)
- strcpy(&Katalog->CDName,si->Buffer);
- else
- strcpy(&Katalog->KE[Einstellungen.Auswahl-1].Titel,si->Buffer);
-
- strcpy(si->Buffer,"");
- RefreshGList(CDPlayerGadgets[24],CDPlayerWnd,NULL,1L);
- Einstellungen.CatChange=1;
- ListeErstellen(FALSE);
- ZeigeTrackDisplay();
- }
- }
- }
-
- void AutoRepeat(item)
- struct MenuItem *item;
- {
- if(item->Flags & CHECKED)
- Einstellungen.AutoRepeat=1;
- else
- Einstellungen.AutoRepeat=0;
- ZeigeCDInfo();
- }
-
- void AutoStart(item)
- struct MenuItem *item;
- {
- if(item->Flags & CHECKED)
- Einstellungen.AutoStart=1;
- else
- Einstellungen.AutoStart=0;
- ZeigeCDInfo();
- }
-
- void AutoSave(item)
- struct MenuItem *item;
- {
- if(item->Flags & CHECKED)
- Einstellungen.AutoSave=1;
- else
- Einstellungen.AutoSave=0;
- }
-
- void AutoLoad(item)
- struct MenuItem *item;
- {
- if(item->Flags & CHECKED)
- Einstellungen.AutoLoad=1;
- else
- Einstellungen.AutoLoad=0;
- }
-
- void AutoFlush(item)
- struct MenuItem *item;
- {
- if(item->Flags & CHECKED)
- Einstellungen.AutoFlush=1;
- else
- Einstellungen.AutoFlush=0;
- }
-
- void Zeit1(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Anzeige=TRACK_ANFANG;
- TesteLaufwerk();
- }
-
- void Zeit2(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Anzeige=CD_ANFANG;
- TesteLaufwerk();
- }
-
- void Zeit3(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Anzeige=TRACK_ENDE;
- TesteLaufwerk();
- }
-
- void Zeit4(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Anzeige=CD_ENDE;
- TesteLaufwerk();
- }
-
- void Format1(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Format=ZEIT;
- TesteLaufwerk();
- }
-
- void Format2(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Format=ADRESSE;
- TesteLaufwerk();
- }
-
- void Format3(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Format=PROZENT;
- TesteLaufwerk();
- }
-
- void Format4(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Format=MEGABYTES;
- TesteLaufwerk();
- }
-
- void JoystickA(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Kontrolle=AUS;
- ZeigeStatus();
- }
-
- void Joystick1(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Kontrolle=JOYSTICK_I;
- ZeigeStatus();
- }
-
- void Joystick2(item)
- struct MenuItem *item;
- {
- item->Flags |= CHECKED;
- Einstellungen.Kontrolle=JOYSTICK_II;
- ZeigeStatus();
- }
-
- void Hilfe()
- {
- register struct NewAmigaGuide *amg;
- struct FileLock *lock;
- APTR ctx;
- UBYTE name[200];
-
- if(AmigaGuideBase!=NULL)
- {
- amg=AllocMem(sizeof(struct NewAmigaGuide),MEMF_CLEAR|MEMF_ANY);
- if(amg!=NULL)
- {
- amg->nag_Name="MusicBox:MusicBox.guide";
- SleepPointer(CDPlayerWnd);
- lock=NULL;
-
- if(Locale)
- {
- sprintf(&name,"MusicBox:%s/MusicBox.guide",Locale->loc_LanguageName);
- lock=Lock(&name,ACCESS_READ);
- if(lock!=NULL)
- {
- UnLock(lock);
- amg->nag_Name=&name;
- }
- }
-
- ctx=OpenAmigaGuide(amg,NULL);
- if(ctx!=NULL)
- CloseAmigaGuide(ctx);
- else
- Error(GS(79,"AmigaGuide is unable to load guide file!"));
-
- ClearPointer(CDPlayerWnd);
- FreeMem(amg,sizeof(struct NewAmigaGuide));
- }
- else
- Error(GS(6,"Not enough memory!"));
- }
- else
- Error(GS(78,"AmigaGuide is not available!"));
- }
-
- void KopplungPressed()
- {
- REGISTER BOOL bool;
- struct TagItem tag[2];
-
- if(Einstellungen.Kopplung)
- { Einstellungen.Kopplung=0; bool=FALSE; }
- else
- { Einstellungen.Kopplung=1; bool=TRUE; }
-
- tag[0].ti_Tag=GTCB_Checked;
- tag[0].ti_Data=bool;
- tag[1].ti_Tag=TAG_DONE;
- GTSetGadgetAttrsA(CDPlayerGadgets[26],CDPlayerWnd,NULL,&tag);
- }
-
- void KopplungClicked(gadgetUp)
- BOOL gadgetUp;
- {
- if(gadgetUp)
- {
- if(CDPlayerGadgets[26]->Flags & SELECTED)
- Einstellungen.Kopplung=1;
- else
- Einstellungen.Kopplung=0;
- }
- }
-
- void TesteLaufwerk()
- {
- ZeigeStatus();
- ZeigeCDInfo();
- if(IsIconify) LeseStatus();
- if(Einstellungen.AutoCnt>0)
- {
- Einstellungen.AutoCnt++;
- if(Einstellungen.AutoCnt>5)
- {
- Einstellungen.AutoCnt=0;
- if(Einstellungen.Funktion==AUTO)
- {
- if(Einstellungen.Auswahlmodus==LISTE)
- Einstellungen.Track=1;
- else
- Einstellungen.Track=Random(ThisCD->Anzahl);
- Symbol(WIEDERGABE);
- WiedergabeClicked();
- Einstellungen.Funktion=WIEDERGABE;
- }
- }
- }
- }
-
- void IntuiTicks()
- {
- if(Einstellungen.Kontrolle) JoystickHandler();
- Einstellungen.IntuiTicks++;
- if(Einstellungen.IntuiTicks>Einstellungen.TickCnt)
- {
- Einstellungen.IntuiTicks=0;
- TesteLaufwerk();
- }
- }
-
- void Iconify()
- {
- BOOL ende;
- ULONG Signale;
- int test;
-
- AppItem=AddAppMenuItemA(0L,0L,"Music Box",AppPort,NULL);
- if(AppItem!=NULL)
- {
- AppIcon=AddAppIconA(1L,0L,"Music Box",AppPort,0L,&CDMusicBox,0L);
- if(AppIcon!=NULL)
- {
- CloseCDPlayerWindow();
- IsIconify=TRUE;
-
- WaitSignalMask=AppSignalMask+ProcessSignalMask+ControlSignalMask+ARexxSignalMask;
- ende=FALSE;
- SichereKatalog();
-
- while(ende==FALSE)
- {
- Signale=Wait(WaitSignalMask);
- if(Signale & AppSignalMask)
- {
- AppMsg=GetMsg(AppPort);
- if(AppMsg!=NULL)
- {
- ende=TRUE;
- ReplyMsg(AppMsg);
- }
- }
- if(Signale & ProcessSignalMask)
- IntuiTicks();
- if(Signale & ControlSignalMask)
- if((ControlHandler())==2) ende=TRUE;
- if(Signale & ARexxSignalMask)
- if((ARexxHandler())==2) ende=TRUE;
- }
-
- test=OpenCDPlayerWindow();
- if(test!=0)
- {
- RemoveAppIcon(AppIcon);
- RemoveAppMenuItem(AppItem);
- CloseAll();
- }
-
- RPort=CDPlayerWnd->RPort;
- ox=OffsetX(CDPlayerWnd);
- oy=OffsetY(CDPlayerWnd);
-
- IDCMPSignalMask=(1L<<CDPlayerWnd->UserPort->mp_SigBit);
- WaitSignalMask=IDCMPSignalMask+ProcessSignalMask+ControlSignalMask+ARexxSignalMask;
-
- Einstellungen.Titel=255;
- Einstellungen.Auswahl=255;
-
- PrefsZeigen();
-
- WarteAufAudio=FALSE;
- IstDatenCD=FALSE;
- IsIconify=FALSE;
- RemoveAppIcon(AppIcon);
- }
- RemoveAppMenuItem(AppItem);
- CDDisplay();
- TesteLaufwerk();
- CleanUpPort(AppPort);
- }
- }
-
-